#include "Scripting.h"

void CScripting::PushFunction( char* sz )
{
	unsigned char uc = 0, uc1 = 0;
	CSquirrel* pScript = NULL;
	while ( ( uc < 250 ) && ( uc1 < CSquirrelManager::Count() ) )
	{
		pScript = CSquirrelManager::Find( uc );
		if ( pScript ) 
		{
			pScript->PushFunction( sz );

			uc1++;
		}
		uc++;
	}
}

void CScripting::PushFunction( void* p )
{
	unsigned char uc = 0, uc1 = 0;
	CSquirrel* pScript = NULL;
	while ( ( uc < 250 ) && ( uc1 < CSquirrelManager::Count() ) )
	{
		pScript = CSquirrelManager::Find( uc );
		if ( pScript ) 
		{
			pScript->PushFunction( p );
			uc1++;
		}
		uc++;
	}
}

void CScripting::PushInteger( int i )
{
	unsigned char uc = 0, uc1 = 0;
	CSquirrel* pScript = NULL;
	while ( ( uc < 250 ) && ( uc1 < CSquirrelManager::Count() ) )
	{
		pScript = CSquirrelManager::Find( uc );
		if ( pScript ) 
		{
			pScript->PushInteger( i );
			uc1++;
		}
		uc++;
	}
}

void CScripting::PushFloat( float f )
{
	unsigned char uc = 0, uc1 = 0;
	CSquirrel* pScript = NULL;
	while ( ( uc < 250 ) && ( uc1 < CSquirrelManager::Count() ) )
	{
		pScript = CSquirrelManager::Find( uc );
		if ( pScript ) 
		{
			pScript->PushFloat( f );
			uc1++;
		}
		uc++;
	}
}

void CScripting::PushString( char* sz )
{
	unsigned char uc = 0, uc1 = 0;
	CSquirrel* pScript = NULL;
	while ( ( uc < 250 ) && ( uc1 < CSquirrelManager::Count() ) )
	{
		pScript = CSquirrelManager::Find( uc );
		if ( pScript ) 
		{
			pScript->PushString( sz );
			uc1++;
		}
		uc++;
	}
}

void CScripting::PushPointer( void* p )
{
	unsigned char uc = 0, uc1 = 0;
	CSquirrel* pScript = NULL;
	while ( ( uc < 250 ) && ( uc1 < CSquirrelManager::Count() ) )
	{
		pScript = CSquirrelManager::Find( uc );
		if ( pScript ) 
		{
			pScript->PushPointer( p );
			uc1++;
		}
		uc++;
	}
}

void CScripting::PushNull( void )
{
	unsigned char uc = 0, uc1 = 0;
	CSquirrel* pScript = NULL;
	while ( ( uc < 250 ) && ( uc1 < CSquirrelManager::Count() ) )
	{
		pScript = CSquirrelManager::Find( uc );
		if ( pScript ) 
		{
			pScript->PushNull();
			uc1++;
		}
		uc++;
	}
}

void CScripting::CallFunction()
{
	unsigned char uc = 0, uc1 = 0;
	CSquirrel* pScript = NULL;
	while ( ( uc < 250 ) && ( uc1 < CSquirrelManager::Count() ) )
	{
		pScript = CSquirrelManager::Find( uc );
		if ( pScript ) 
		{
			pScript->CallFunction();
			uc1++;
		}
		uc++;
	}
}